<?php

namespace App\Console\Commands;

use App\model\Coustomer;
use App\model\Industry;
use App\model\Jinri;
use App\model\Project;
use DemeterChain\C;
use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;
use GuzzleHttp\Exception\RequestException;
use GuzzleHttp\Pool;
use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Response;
use Illuminate\Console\Command;
use Illuminate\Support\Carbon;
use Illuminate\Support\Facades\Log;
use Psr\Http\Message\ResponseInterface;

class Hello extends Command
{
    protected  $key=[
        'xinxing'=> [
            'token'=>'6c351de4f2c2e1b344c67063f8bb4e2cd5670082',
            'key'=>'OFpST1JZQTVITkM1',
            'project_id'=>17
        ],
        'xinxing1'=> [
            'token'=>'48f585bb1df03147423b2413d5bab75bade7fa0f',
            'key'=>'RkFHMUo0RklJU0RU',
            'project_id'=>17
        ],
        'shiyou'=> [
            'token'=>'8acde9998b7ace3e80ec140311d3ee66116f7f13',
            'key'=>'UVFYNk9KRzUwOE9O',
            'project_id'=>4
        ],
        'shiyou2'=> [
            'token'=>'f8581be0d5867ed7cc89abd641f0b086aa630b63',
            'key'=>'MUszVzM0TUdKM0VC',
            'project_id'=>15
        ],
        'shiyou3'=> [
            'token'=>'1b4a4c1e3e6fc1e7b855227f3d63edcc810433a1',
            'key'=>'QVVRSEg0RVBHUDdF',
            'project_id'=>15
        ],
        'zhaoshang'=> [
            'token'=>'a74afd963ac0d3d6ca846d4aba6db406debe8050',
            'key'=>'UzZRWkhKWUxJRDM2',
            'project_id'=>13
        ],
        'huateng'=> [
            'token'=>'598d2eaa749f0264bb0099362687610564844ff0',
            'key'=>'QUFRWTNXOEdQNTA0',
            'project_id'=>19
        ],
        'huateng1'=> [
            'token'=>'de4cf6122de218aeaa2a7526396b8e0ae9997482',
            'key'=>'MjVBNlkyMEw0UDlN',
            'project_id'=>19
        ],
        'huateng2'=> [
            'key'=>'UVcyV1JKTE41NFBM',
            'token'=>'04622c2bb5921c604df6f0a2fc8a0187c72b3758',
            'project_id'=>23
        ],
        'huateng3'=> [
            'token'=>'87e482c5279de9522f3a5b90607ec2ad65126ead',
            'key'=>'R0RXN0s2VDUxRlNB',
            'project_id'=>23
        ],
        'huatengRui'=> [
            'token'=>'bce2aaa3302cac04fe6b8a269ec8a1933be3b8a0',
            'key'=>'TVhZOEQ0Mjg5Rk9V',
            'project_id'=>20
        ],

        'xinxing2'=>[
            'token'=>'5685a7ca0f4dcac954338bd0f1cb1827bfb4ca07',
            'key'=>'MjZJU05MUDlHUlkw',
            'project_id'=>22
        ],
        'xinxing3'=>[
            'token'=>'dce85204b3ea6897f64700eba8fd3e0abd33851c',
            'key'=>'WEpQRTAyRENZN1VE',
            'project_id'=>22
        ],


    ];
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'hello';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = 'Command description';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {

       $http= new Client();
      $result= $http->post('https://aip.baidubce.com/rpc/2.0/nlp/v2/word_emb_sim',[
           'query'=>[
               'access_token'=>$this->getToken(),
               'charset'=>'UTF-8'
           ],
           'json'=>[
               'word_1'=>'机械设备',
               'word_2'=>'五金机械'
           ]
       ]);
        $response=json_decode( $result->getBody()->getContents(),true);
        dd($response);
    }
    protected function getToken(){
        $http=  new Client();
        $result= $http->post('https://aip.baidubce.com/oauth/2.0/token',[
            'form_params'=>[
                'grant_type'=>'client_credentials',
                'client_id'=>'NhXSEXGYB5l4GO3Yxhwiwj08',
                'client_secret'=>'LHdza5x0Cln5Q4OuotnG1pND9zVemtBB',
            ]
        ]);
        $response=json_decode( $result->getBody()->getContents(),true);
        return $response['access_token'];
    }
}
